home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / ov143b.zip / OVDEF.C < prev    next >
C/C++ Source or Header  |  1993-01-04  |  25KB  |  751 lines

  1. /*  026  02-Jun-87  ovdef.c
  2.  
  3.         Copyright (c) 1987 by Blue Sky Software.  All rights reserved.
  4. */
  5.  
  6. #include <stdio.h>
  7. #include "ov.h"
  8. #include "overr.h"
  9. #include "menu.h"
  10. #include "dialog.h"
  11. #include "direct.h"
  12.  
  13. #define CFG_VERSION 2  /* <======<<<< incr when parameter file layout changes */
  14.  
  15. extern WINDOW cw;                      /* current window structure */
  16.  
  17. extern unsigned char vid_mode;         /* need to know video mode */
  18. extern unsigned char vid_attrib;       /* we hack directly with video attrib */
  19. extern unsigned char restricted;       /* NZ when some functions disabled */
  20. extern unsigned char def_display;      /* NZ when define screen displayed */
  21. extern unsigned char attribs[];        /* array of attrib's */
  22. extern char *cantopen;                 /* common text message */
  23.  
  24. extern MENU top_file_menu[], *top_menu;
  25.  
  26. int def_color(), def_exit(), def_pag(), def_udk();
  27. int def_set(), def_noset(), def_reset(), def_snow(), def_nosnow();
  28.  
  29. static MENU snow_menu[] = {
  30.    { "Disable", "Disable \"snow\" checking", def_nosnow, NULL },
  31.    { "Enable",  "Enable \"snow\" checking", def_snow, NULL },
  32.    { NULL, NULL, NULL, NULL }
  33. };
  34.  
  35. static MENU set_attr_menu[] = {
  36.    { "Set", "Set color attributes to values shown", def_set, NULL },
  37.    { "Reset", "Reset color attributes to prior values", def_reset, NULL },
  38.    { "Quit", "Quit without changing color attributes", def_noset, NULL },
  39.    { NULL, NULL, NULL, NULL }
  40. };
  41.  
  42. static MENU top_def_menu[] = {
  43.    { "Colors", "Select video display attributes", def_color, set_attr_menu },
  44.    { "Snow", "Enable/disable video \"snow\" checking", NULL, snow_menu },
  45.    { "Point-and-Go", "Modify Point-and-Go parameters", def_pag, NULL },
  46.    { "UDK", "Modify User Defined Keys", def_udk, NULL },
  47.    { "Quit", "Quit chaning Define parameters", def_exit, top_file_menu },
  48.    { NULL, NULL, NULL, NULL }
  49. };
  50.  
  51. static char *def_text[] =
  52.    { "NORMAL TEXT            ", "HIGHLIGHTED TEXT       ",
  53.      "WINDOW TEXT            ", "HIGHLIGHTED WINDOW TEXT",
  54.      "HEADING TEXT           ", "BACKGROUND TEXT        ",
  55.      "TAGGED FILE NAME TEXT  " };
  56.  
  57. static char *directions[] = {
  58.      "PgUp & PgDn select the ", "type of text to be set.",
  59.      "                       ", "\x18\x19\x1b\x1a select the colors." };
  60.  
  61. static int changed;
  62. static int text_type;
  63. static char *ovcfg = "OV.CFG";
  64. static unsigned char newattr[7];
  65. static char dirliteral[] = "Directions";
  66. static char ent2up[] = "Enter number to update:";
  67.  
  68. /* allocate the dialog boxes and fields for def_*() routines */
  69.  
  70. static D_BOX text_box =  { 3, 2, 7, 25, NULL, NULL };
  71. static D_BOX video_box = { 3, 30, 16, 48, NULL, NULL };
  72. static D_BOX dir_box =   { 14, 2, 4, 25, NULL, dirliteral };
  73. static D_BOX pag_box =   { 7, 10, 14, 61, NULL, "Set Point-and-Go Parameters" };
  74. static D_BOX udk_box =   { 7, 10, 14, 62, NULL, "Set User-Defined-Keys" };
  75. static D_FLD pag_fld;
  76. static D_FLD udk_fld;
  77.  
  78. /****************************************************************************
  79.  Following is the parameter area which holds all user specified parameters.
  80.  This area is updated by the routines in OVDEF.C.  Be very very careful when
  81.  modifying this area.  Make sure that routine def_write() is correct.
  82.  ****************************************************************************/
  83.  
  84. static unsigned char cfgver = CFG_VERSION;   /* config layout version # */
  85.  
  86. unsigned char vid_snow = 1;            /* NZ if must chk for video snow */
  87.  
  88. /* Define the video display attributes.  One set for mono, one for CGA. */
  89. /* The attributes are in the following order:                           */
  90. /* DIS_NORM, DIS_HIGH, DIS_BOX, DIS_HIBOX, DIS_HEAD, DIS_TEXT, DIS_TAGD */
  91.  
  92. unsigned char monattr[] = { 0x07, 0x70, 0x0F, 0x70, 0x70, 0x07, 0x0F }; /*mono*/
  93. unsigned char cgaattr[] = { 0x0B, 0x30, 0x0E, 0x30, 0x1B, 0x0A, 0x0E }; /* cga*/
  94.  
  95. /* Define the Point-and-Go parameters and the User-Defined-Keys */
  96.  
  97. PAG_ENT pag_tbl[NUM_PAG];
  98. UDK_ENT udk_tbl[NUM_UDK];
  99.  
  100. /*****************************************************************************
  101.                          End of parameter area
  102.  *****************************************************************************/
  103.  
  104. char *getenv(), *strchr();
  105. FILE *fopen(), *pathopen();
  106.  
  107. #ifdef LINT_ARGS
  108. void dispagent(int), rdpagent(int);
  109. void disudkent(int), rdudkent(int);
  110. void ALTCALL rdyesno(D_BOX *, D_FLD *, unsigned char *, int);
  111. char * ALTCALL rd_p_u_fld(D_BOX *, D_FLD *, int, int, char *);
  112. void ALTCALL pag_or_udk(D_BOX *, void (*)(), void (*)(), int, char *);
  113. #else
  114. char * ALTCALL rd_p_u_fld();
  115. void dispagent(), rdpagent();
  116. void disudkent(), rdudkent();
  117. void ALTCALL rdyesno(), ALTCALL pag_or_udk();
  118. #endif
  119.  
  120. /*****************************************************************************
  121.                                D E F I N E
  122.  *****************************************************************************/
  123.  
  124. define() {     /* allow user to define various parameters */
  125.  
  126.    changed = FALSE;            /* nothing changed so far    */
  127.    restricted = TRUE;          /* don't allow some commands */
  128.    top_menu = top_def_menu;    /* make define menu THE menu */
  129. }
  130.  
  131.  
  132. /*****************************************************************************
  133.                             D E F _ E X I T
  134.  *****************************************************************************/
  135.  
  136. static int
  137. def_exit() {           /* leave define screen parameters mode */
  138.  
  139.    int write;
  140.  
  141.    /* if the user changed anything, ask him if the parameters should be
  142.       written to disk.  If he says yea, then do it. */
  143.  
  144.    if (changed) {
  145.       write = ask("Write changed parameters to disk? (y/N): ");
  146.       if (yes(write))
  147.          def_write();
  148.    }
  149.  
  150.    top_menu = top_file_menu;           /* file menu again */
  151.    restricted = FALSE;                 /* allow everything again */
  152. }
  153.  
  154.  
  155. /*****************************************************************************
  156.                             D E F _ C O L O R
  157.  *****************************************************************************/
  158.  
  159. static int
  160. def_color() {          /* define screen "colors" */
  161.  
  162.    strncpy(newattr,attribs,sizeof(newattr));   /* start with current attribs */
  163.  
  164.    def_display = TRUE;                 /* define color display is active */
  165.    restricted = FALSE;                 /* allow the cursor keys to work  */
  166.    top_menu = set_attr_menu;           /* so ESC doesn't leave this menu */
  167.  
  168.    def_init();                         /* actually setup the color display */
  169.  
  170.    select_t(1,text_type = DIS_NORM);   /* highlight normal text first */
  171.    select_a(1,newattr[text_type]);     /* highlight current attr location */
  172. }
  173.  
  174.  
  175. /*****************************************************************************
  176.                             D E F _ x S E T
  177.  *****************************************************************************/
  178.  
  179. static int
  180. def_set() {            /* use the currently displayed video attributes */
  181.  
  182.    changed = TRUE;                             /* assume they changed some */
  183.    strncpy(attribs,newattr,sizeof(newattr));   /* SET the current values */
  184.    do_set();                                   /* rest of stuff */
  185. }
  186.  
  187. static int
  188. def_noset() {          /* back to the prior values */
  189.  
  190.    strncpy(newattr,attribs,sizeof(newattr));   /* back to current */
  191.    do_set();
  192. }
  193.  
  194. static int
  195. def_reset() {          /* reset to OverView default/config file value */
  196.  
  197.    changed = TRUE;                             /* assume some change */
  198.    strncpy(attribs,vid_mode == 7 ? monattr : cgaattr,sizeof(newattr));
  199.    strncpy(newattr,attribs,sizeof(newattr));   /* back to default */
  200.    do_set();
  201. }
  202.  
  203. static int
  204. do_set() {
  205.    setup_file_scr();                           /* rewrite file screen */
  206.    update_header();                            /* to use possible new colors */
  207.    refresh_screen(0);
  208.  
  209.    restricted = TRUE;                          /* disable cursor keys    */
  210.    def_display = FALSE;                        /* back to normal display */
  211.    top_menu = top_def_menu;                    /* back to define menu    */
  212. }
  213.  
  214.  
  215. /*****************************************************************************
  216.                             D E F _ I N I T
  217.  *****************************************************************************/
  218.  
  219. static int
  220. def_init() {           /* initialize the define colors screen */
  221.  
  222.    int i, fg;
  223.    register int bg;
  224.  
  225.    /* initialize the screen image */
  226.  
  227.    setvattrib(DIS_NORM);
  228.  
  229.    clr_scr();
  230.    center_text(0,"DEFINE SCREEN COLORS");
  231.  
  232.    disp_status();                              /* status line */
  233.  
  234.    setvattrib(DIS_BOX);                        /* box to enclose text types */
  235.    dbx_open(&text_box,0);
  236.  
  237.    for (i = DIS_NORM; i <= DIS_TAGD; i++)      /* display text types */
  238.       select_t(0,i);
  239.  
  240.    setvattrib(DIS_BOX);                        /* box to enclose pattern */
  241.    dbx_open(&video_box,0);
  242.  
  243.    for (fg = 0; fg < 16; fg++) {               /* display color pattern */
  244.       dbx_goto(&video_box,fg,0);
  245.       for (bg = 0; bg < 8; bg++) {
  246.          vid_attrib = (bg << 4) | fg;
  247.          disp_str(" TEXT ");
  248.       }
  249.    }
  250.  
  251.    setvattrib(DIS_BOX);               /* box for directions/instructions */
  252.    dbx_open(&dir_box,0);
  253.  
  254.    for(i = 0; i < 4; i++)                      /* display the directions */
  255.       dbx_disp(&dir_box,directions[i],i,1);
  256.  
  257.    setvattrib(DIS_NORM);       /* back to "Normal" */
  258.  
  259. }
  260.  
  261.  
  262. /****************************************************************************
  263.                           P A G _ O R _ U D K
  264.  ***************************************************************************/
  265.  
  266. void ALTCALL
  267. pag_or_udk(dbp,df,rf,num_ent,head)     /* define PAG or UDK entries */
  268. D_BOX *dbp;
  269. void (*df)();
  270. void (*rf)();
  271. int num_ent;
  272. char *head;
  273. {
  274.    char *tmp;
  275.    register int i;
  276.    static D_FLD num_fld = { 13, 40, 3, 0, "   " };
  277.  
  278.    /* pop up the dialog box to use */
  279.  
  280.    setvattrib(DIS_BOX);                /* open dialog box */
  281.    dbx_open(dbp,DBX_SAVE);
  282.  
  283.    setvattrib(DIS_HEAD);               /* display header */
  284.    dbx_disp(dbp,head,0,0);
  285.  
  286.    setvattrib(DIS_BOX);                /* display existing entries */
  287.    for (i = 0; i < num_ent; i++)
  288.       (*df)(i);
  289.  
  290.    dbx_disp(dbp,ent2up,13,16);         /* entry to update msg */
  291.  
  292.    /* read entries from user */
  293.  
  294.    while (TRUE) {
  295.       setvattrib(DIS_HIBOX);
  296.  
  297.       if (!*(tmp = dbx_rdfld(dbp,&num_fld)))   /* get # of ent to read */
  298.          break;
  299.  
  300.       i = atoi(tmp) - 1;                       /* ascii to integer     */
  301.  
  302.       if (i >= 0 && i < num_ent) {             /* within range?        */
  303.          (*df)(i);                             /* disp ent with HIBOX  */
  304.          (*rf)(i);                             /* read it from user    */
  305.          setvattrib(DIS_BOX);                  /* redisplay with BOX   */
  306.          (*df)(i);                             /* disp ent with HIBOX  */
  307.       }
  308.    }
  309.  
  310.    setvattrib(DIS_NORM);       /* back to normal */
  311.  
  312.    dbx_close(dbp);             /* close the dialog box */
  313. }
  314.  
  315.  
  316. /*****************************************************************************
  317.                               D E F _ P A G
  318.  *****************************************************************************/
  319.  
  320. static int
  321. def_pag() {    /* define the Point and Go parameters */
  322.  
  323.    pag_or_udk(&pag_box,dispagent,rdpagent,NUM_PAG,
  324.               " NUM EXT  COMMAND PROTOTYPE                       PAUSE READ ");
  325. }
  326.  
  327.  
  328. /**************************************************************************
  329.                            D I S P A G E N T
  330.  **************************************************************************/
  331.  
  332. #define NUM_COL (1)            /* offsets within the PAG dialog box */
  333. #define EXT_COL (5)
  334. #define CMD_COL (10)
  335. #define PAUSE_COL (52)
  336. #define READ_COL (58)
  337.  
  338. static void
  339. dispagent(ent) /* display PAG entry number ent */
  340. int ent;
  341. {
  342.    int row = ent + 2;
  343.    register PAG_ENT *pp = &pag_tbl[ent];
  344.  
  345.    dbx_goto(&pag_box,row,NUM_COL);
  346.    out_int(ent+1,3,' ');
  347.    dbx_goto(&pag_box,row,EXT_COL);
  348.    out_str(pp->used ? pp->ext : "",sizeof(pp->ext)-1,' ');
  349.    dbx_goto(&pag_box,row,CMD_COL);
  350.    out_str(pp->used ? pp->cmd : "",sizeof(pp->cmd)-1,' ');
  351.    dbx_disp(&pag_box,pp->used ? (pp->pause ? "Y" : "N") : " ",row,PAUSE_COL);
  352.    dbx_disp(&pag_box,pp->used ? (pp->reload ? "Y" : "N") : " ",row,READ_COL);
  353. }
  354.  
  355. /*****************************************************************************
  356.                               R D P A G E N T
  357.  ****************************************************************************/
  358.  
  359. static void
  360. rdpagent(ent)  /* read a PAG entry from the user */
  361. int ent;
  362. {
  363.    int row = ent + 2;
  364.    register PAG_ENT *pp = &pag_tbl[ent];
  365.  
  366.    pag_fld.pos = 0;
  367.    pag_fld.row = row;
  368.  
  369.    /* read the ext field for this entry, if nothing is read, blank (delete)
  370.       this entry. */
  371.  
  372.    if (*rd_p_u_fld(&pag_box,&pag_fld,EXT_COL,sizeof(pp->ext)-1,pp->ext)) {
  373.  
  374.       pp->used = 1;            /* ext isn't blank, entry in use */
  375.  
  376.       /* read command prototype field */
  377.  
  378.       rd_p_u_fld(&pag_box,&pag_fld,CMD_COL,sizeof(pp->cmd)-1,pp->cmd);
  379.  
  380.       rdyesno(&pag_box,&pag_fld,&pp->pause,PAUSE_COL); /* pause after running */
  381.       rdyesno(&pag_box,&pag_fld,&pp->reload,READ_COL); /* reread dir after    */
  382.  
  383.    } else {            /* blank ext field, no entry */
  384.  
  385.       *pp->ext = *pp->cmd = '\0';
  386.       pp->used = pp->pause = pp->reload = 0;
  387.    }
  388.  
  389.    changed = TRUE;             /* assume something changed */
  390. }
  391.  
  392. #undef NUM_COL
  393. #undef EXT_COL
  394. #undef CMD_COL
  395. #undef PAUSE_COL
  396. #undef READ_COL
  397.  
  398.  
  399. /*****************************************************************************
  400.                               D E F _ U D K
  401.  *****************************************************************************/
  402.  
  403. static int
  404. def_udk() {    /* define the User Defined Keys */
  405.  
  406.    pag_or_udk(&udk_box,disudkent,rdudkent,NUM_UDK,
  407.               " NUM  KEY  COMMAND PROTOTYPE                       PAUSE READ ");
  408. }
  409.  
  410. /**************************************************************************
  411.                            D I S U D K E N T
  412.  **************************************************************************/
  413.  
  414. #define NUM_COL (1)            /* offsets within the UDK dialog box */
  415. #define KEY_COL (5)
  416. #define CMD_COL (11)
  417. #define PAUSE_COL (53)
  418. #define READ_COL (59)
  419.  
  420. static void
  421. disudkent(ent) /* display UDK entry number ent */
  422. int ent;
  423. {
  424.    int row = ent + 2;
  425.    register UDK_ENT *up = &udk_tbl[ent];
  426.  
  427.    dbx_goto(&udk_box,row,NUM_COL);
  428.    out_int(ent+1,2,' ');
  429.    dbx_disp(&udk_box,"A-F",row,KEY_COL);
  430.    out_int(ent+1,1+(ent >= 9),' ');
  431.    dbx_goto(&udk_box,row,CMD_COL);
  432.    out_str(up->used ? up->cmd : "",sizeof(up->cmd)-1,' ');
  433.    dbx_disp(&udk_box,up->used ? (up->pause ? "Y" : "N") : " ",row,PAUSE_COL);
  434.    dbx_disp(&udk_box,up->used ? (up->reload ? "Y" : "N") : " ",row,READ_COL);
  435. }
  436.  
  437.  
  438. /*****************************************************************************
  439.                               R D U D K E N T
  440.  ****************************************************************************/
  441.  
  442. static void
  443. rdudkent(ent)  /* read a UDK entry from the user */
  444. int ent;
  445. {
  446.    int row = ent + 2;
  447.    register UDK_ENT *up = &udk_tbl[ent];
  448.  
  449.    udk_fld.pos = 0;
  450.    udk_fld.row = row;
  451.  
  452.    /* read the CMD field for this entry, if nothing is read, blank (delete)
  453.       this entry. */
  454.  
  455.    if (*rd_p_u_fld(&udk_box,&udk_fld,CMD_COL,sizeof(up->cmd)-1,up->cmd)) {
  456.  
  457.       up->used = 1;            /* cmd isn't blank, entry in use */
  458.  
  459.       rdyesno(&udk_box,&udk_fld,&up->pause,PAUSE_COL); /* pause after running */
  460.       rdyesno(&udk_box,&udk_fld,&up->reload,READ_COL); /* read dir            */
  461.  
  462.    } else {            /* blank cmd field, no entry */
  463.  
  464.       *up->cmd = '\0';
  465.       up->used = up->pause = up->reload = 0;
  466.    }
  467.  
  468.    changed = TRUE;             /* assume something changed */
  469. }
  470.  
  471. #undef NUM_COL
  472. #undef KEY_COL
  473. #undef CMD_COL
  474. #undef PAUSE_COL
  475. #undef READ_COL
  476.  
  477.  
  478. /***************************************************************************
  479.                           R D _ P _ U _ F L D
  480.  ***************************************************************************/
  481.  
  482. static char * ALTCALL
  483. rd_p_u_fld(dbp,dfp,col,len,value)      /* read 1 pag or udk field from user */
  484. D_BOX *dbp;
  485. register D_FLD *dfp;
  486. int col, len;
  487. char *value;
  488. {
  489.    char *tmp;
  490.  
  491.    dfp->col = col;
  492.    dfp->len = len;
  493.    dfp->value = value;
  494.    if (*(tmp = dbx_rdfld(dbp,dfp)))
  495.       strcpy(dfp->value,tmp);
  496.    return(tmp);
  497. }
  498.  
  499.  
  500. /****************************************************************************
  501.                                R D Y E S N O
  502.  ****************************************************************************/
  503.  
  504. static void ALTCALL
  505. rdyesno(dbp,dfp,ynp,col)       /* read a yes/no value into a 0/1 integer */
  506. D_BOX *dbp;
  507. D_FLD *dfp;
  508. unsigned char *ynp;
  509. int col;
  510. {
  511.    char yesno[2];
  512.  
  513.    *yesno = *ynp ? 'Y' : 'N';          /* convert 0/NZ to Y/N */
  514.    yesno[1] = '\0';
  515.  
  516.    rd_p_u_fld(dbp,dfp,col,1,yesno);    /* read from user      */
  517.    *ynp = yes(*yesno);                 /* convert Y/N to 0/1  */
  518. }
  519.  
  520.  
  521. /*****************************************************************************
  522.                        D E F _ S N O W / N O S N O W
  523.  *****************************************************************************/
  524.  
  525. static int
  526. def_snow() {   /* enable video snow checking */
  527.  
  528.    vid_snow = 1;
  529.    changed = TRUE;
  530. }
  531.  
  532. static int
  533. def_nosnow() { /* disable snow checking */
  534.  
  535.    vid_snow = 0;
  536.    changed = TRUE;
  537. }
  538.  
  539.  
  540. /*****************************************************************************
  541.                             D E F _ R E A D
  542.  *****************************************************************************/
  543.  
  544. def_read() {   /* read parameters from configuration file */
  545.  
  546.    FILE *cfg;
  547.    unsigned char filever = 0;
  548.  
  549.    /* try to open the CFG (configuration) file somewhere in the current
  550.       PATH - if we don't find an existing file assume there isn't one and
  551.       use the default values */
  552.  
  553.    if ((cfg = pathopen(ovcfg,"rb")) == NULL)   /* try to open config file */
  554.       return;                                  /* must not be one, exit   */
  555.  
  556.    /* make sure we know how to read this form of config file */
  557.  
  558.    fread(&filever,1,1,cfg);
  559.    if (filever != CFG_VERSION) {
  560.       show_error(0,0,1,"Obsolete configuration file, defaults used");
  561.       return;
  562.    }
  563.  
  564.    /* looks okay, read parameters */
  565.  
  566.    fread(&vid_snow,1,1,cfg);                     /* read video snow flag   */
  567.    fread(monattr,sizeof(monattr),1,cfg);         /* then mono video attr's */
  568.    fread(cgaattr,sizeof(cgaattr),1,cfg);         /* then cga  video attr's */
  569.    fread((char *)pag_tbl,sizeof(pag_tbl),1,cfg); /* then Point-and-Go tbl  */
  570.    fread((char *)udk_tbl,sizeof(udk_tbl),1,cfg); /* then User-Defined-Keys */
  571.  
  572.    fclose(cfg);                                  /* done reading, close */
  573.  
  574.    /* attributes have been read, copy them to the in-use attributes */
  575.  
  576.    strncpy(attribs,vid_mode == 7 ? monattr : cgaattr,sizeof(newattr));
  577. }
  578.  
  579.  
  580. /*****************************************************************************
  581.                             D E F _ W R I T E
  582.  *****************************************************************************/
  583.  
  584. static int
  585. def_write() {  /* write the updated parameters to disk */
  586.  
  587.    char *sp;
  588.    FILE *cfg;
  589.    register int ch;
  590.    static char *nowrit = " - parameters not written";
  591.  
  592.    /* try to open the CFG (configuration) file somewhere in the current
  593.       PATH - if we don't find an existing file, ask the user where he
  594.       wants it created */
  595.  
  596.    if ((cfg = pathopen(ovcfg,"r+b")) == NULL) {
  597.       char cfgmsg[80];
  598.  
  599.       strcpy(cfgmsg,"Can't find ");
  600.       strcat(cfgmsg,ovcfg);
  601.       strcat(cfgmsg,", enter target directory (ENTER = current, ESC to quit):");
  602.  
  603.       sp = prompt(NULL,cfgmsg,cw.dirbuf,strlen(cw.dirbuf),MAX_PATHLEN);
  604.  
  605.       if (strlen(sp)) {
  606.          char cfgbuf[MAX_PATHLEN+MAX_NAMELEN+3];
  607.  
  608.          strcpy(cfgbuf,sp);                            /* build full pathname */
  609.          if ((ch = cfgbuf[strlen(cfgbuf)-1]) != '\\' && ch != '/' && ch != ':')
  610.             strcat(cfgbuf,"\\");
  611.          strcat(cfgbuf,ovcfg);
  612.  
  613.          if ((cfg = fopen(cfgbuf,"w+b")) == NULL) {    /* try to open 4 WRITE */
  614.             show_error(0,0,3,cantopen,ovcfg,nowrit);   /* give up if can't opn*/
  615.             return;
  616.          }
  617.  
  618.       } else                   /* user must have ESCaped out, just exit */
  619.          return;
  620.  
  621.    } else                      /* pathopen() found it! */
  622.  
  623.       fseek(cfg,0L,SEEK_CUR);  /* was opened 4 READ, seek so we can write */
  624.  
  625.    /*** CFG file is now open, write the parameters ***/
  626.  
  627.    /* now that parms are being written, make video attrib's "permanent" */
  628.  
  629.    strncpy(vid_mode == 7 ? monattr : cgaattr,attribs,sizeof(newattr));
  630.  
  631.    fwrite(&cfgver,1,1,cfg);                /* start with config file version */
  632.    fwrite(&vid_snow,1,1,cfg);                      /* then video snow flag   */
  633.    fwrite(monattr,sizeof(monattr),1,cfg);          /* then mono video attr's */
  634.    fwrite(cgaattr,sizeof(cgaattr),1,cfg);          /* then cga  video attr's */
  635.    fwrite((char *)pag_tbl,sizeof(pag_tbl),1,cfg);  /* then Point-and-Go tbl  */
  636.    fwrite((char *)udk_tbl,sizeof(udk_tbl),1,cfg);  /* then User-Defined-Keys */
  637.  
  638.    fclose(cfg);                                /* done, close */
  639. }
  640.  
  641.  
  642. /*****************************************************************************
  643.                             D E F _ M O V E
  644.  *****************************************************************************/
  645.  
  646. def_move(dir)          /* move the attribute pointer in given direction */
  647. int dir;
  648. {
  649.    register unsigned int fbg, attr = newattr[text_type];
  650.  
  651.    select_a(0,attr);                   /* always deselect video attribute */
  652.  
  653.    if (dir == PGUP || dir ==PGDN)      /* maybe deselect text type */
  654.       select_t(0,text_type);
  655.  
  656.    switch (dir) {
  657.  
  658.       case UP:                                 /* up arrow of course */
  659.  
  660.          if (fbg = attr & 15)
  661.             attr = (attr & 0x70) | (fbg - 1);
  662.          else
  663.             attr = (attr & 0x70) | 15;         /* wraps to bottom */
  664.          break;
  665.  
  666.       case DOWN:                               /* down arrow */
  667.  
  668.          if ((fbg = attr & 15) < 15)
  669.             attr = (attr & 0x70) | (fbg + 1);
  670.          else
  671.             attr = attr & 0x70;                /* wraps to top */
  672.          break;
  673.  
  674.       case LEFT:                               /* left arrow */
  675.  
  676.          if (fbg = (attr >> 4) & 7)
  677.             attr = ((fbg - 1) << 4) | (attr & 15);
  678.          else
  679.             attr = 0x70 | (attr & 15);         /* wraps to right */
  680.          break;
  681.  
  682.       case RIGHT:                              /* right arrow */
  683.  
  684.          if ((fbg = (attr >> 4) & 7) < 7)
  685.             attr = ((fbg + 1) << 4) | (attr & 15);
  686.          else
  687.             attr = attr & 15;                  /* wraps to left */
  688.          break;
  689.  
  690.       case PGUP:                               /* page up - new text type */
  691.  
  692.          if (text_type)
  693.             --text_type;
  694.          else
  695.             text_type = 6;
  696.          break;
  697.  
  698.       case PGDN:                               /* page dn - new text type */
  699.  
  700.          if (text_type < 6)
  701.             ++text_type;
  702.          else
  703.             text_type = 0;
  704.          break;
  705.    }
  706.  
  707.    if (dir == PGUP || dir ==PGDN)              /* maybe select new text type */
  708.       attr = newattr[text_type];               /* set attribute for new type */
  709.  
  710.    select_a(1,attr);                   /* show new attribute */
  711.    newattr[text_type] = attr;          /* remember what it is */
  712.  
  713.    select_t(1,text_type);              /* display name in new attr */
  714.  
  715.    setvattrib(DIS_NORM);               /* stick with norm for now */
  716. }
  717.  
  718.  
  719. /*****************************************************************************
  720.                             S E L E C T _ A
  721.  *****************************************************************************/
  722.  
  723. static int
  724. select_a(on_off,attr)  /* highlight the current attribute */
  725. register int on_off, attr;
  726. {
  727.    vid_attrib = attr;                  /* gotta use this attribute */
  728.  
  729.    dbx_disp(&video_box,on_off ? "\x10TEXT\x11" : " TEXT ",  /* (de)select */
  730.             (attr & 15),((attr >> 4) * 6));
  731. }
  732.  
  733.  
  734. /*****************************************************************************
  735.                             S E L E C T _ T
  736.  *****************************************************************************/
  737.  
  738. static int
  739. select_t(on_off,type)  /* highlight the current text type */
  740. register int on_off, type;
  741. {
  742.    vid_attrib = newattr[type];         /* gotta use this attribute */
  743.  
  744.    /* display pointer, name, pointer */
  745.  
  746.    dbx_goto(&text_box,type,0);
  747.    disp_char(on_off ? 0x10 : ' ');
  748.    disp_str(def_text[type]);
  749.    disp_char(on_off ? 0x11 : ' ');
  750. }
  751.